import Vue from "vue";
import Router from "vue-router";
import Home from "@/components/Pages/home";
import Section from "@/components/Pages/section";
import EditIndex from "@/components/Pages/Edit/index";
import EditArtical from "@/components/Pages/Edit/artical";
import EditQuestion from "@/components/Pages/Edit/question";
import EditGoods from "@/components/Pages/Edit/goods";
import EditIdea from "@/components/Pages/Edit/idea";
import EditLostandfound from "@/components/Pages/Edit/lostandfound";
import MessageIndex from "@/components/Pages/Message/index";
import MessageChat from "@/components/Pages/Message/chat";
import MessageReply from "@/components/Pages/Message/reply";
import MessageAtme from "@/components/Pages/Message/atme";
import MessageSystem from "@/components/Pages/Message/system";
import AccountIndex from "@/components/Pages/Account/index";
import AccountLogin from "@/components/Pages/Account/login";
import AccountRegister from "@/components/Pages/Account/register";
import AccountPasswordFind from "@/components/Pages/Account/Password/find";
import AccountPasswordChange from "@/components/Pages/Account/Password/change";
import AccountBindPhone from "@/components/Pages/Account/Bind/phone";
import AccountBindEmail from "@/components/Pages/Account/Bind/email";
import AccountUserinfo from "@/components/Pages/Account/userinfo";
import AccountUserindex from "@/components/Pages/Account/userindex";
import FriendSearch from "@/components/Pages/Friend/search.vue";
import FriendRequestIndex from "@/components/Pages/Friend/Request/index";
import FriendRequestList from "@/components/Pages/Friend/Request/list";
import FriendRequestHandle from "@/components/Pages/Friend/Request/handle";
import FriendList from "@/components/Pages/Friend/list";
import FriendSettingMarkname from "@/components/Pages/Friend/Setting/markname";
import UserCollect from "@/components/Pages/User/collect";
import UserFellow from "@/components/Pages/User/fellow";
import UserViewrecord from "@/components/Pages/User/viewrecord";
import UserRelease from "@/components/Pages/User/release";
import UserComment from "@/components/Pages/User/comment";
import Advice from "@/components/Pages/advice";
import Report from "@/components/Pages/report";
import SearchIndex from "@/components/Pages/Search/index";
import SearchResult from "@/components/Pages/Search/result";
import Topic from "@/components/Pages/topic";
import Comment from "@/components/Pages/comment";
Vue.use(Router);
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};
// // 路由守卫配置，有些需要登录的页面只有验证登录了才会跳转，否则跳转至登录页面
// router.beforeEach((to, from, next) => {
//   // 判断to页面是否需要登录认证，并判断用户是否登录
//   if (to.meta.requiresAuth && !store.getters.isAuthenticated) {
//     // 判断获取用户信息请求是否加载完成，如果加载完成，说明用户的确没有登录，跳转至登录页面
//     if (store.getters.loadDone) {
//       next({ name: "login" });
//     } else {
//       next();
//     }
//   } else next();
// });
export default new Router({
  routes: [
    {
      path: "/",
      name: "index",
      redirect:'/home'
    },
    {
      path: "/home",
      name: "home",
      component: Home,
    },
    {
      path: "/section",
      name: "section",
      component: Section,
    },
    {
      path: "/edit",
      name: "edit",
      component: EditIndex,
    },
    {
      path: "/edit/artical",
      name: "edit_artical",
      component: EditArtical,
    },
    {
      path: "/edit/question",
      name: "edit_question",
      component: EditQuestion,
    },
    {
      path: "/edit/goods",
      name: "edit_goods",
      component: EditGoods,
    },
    {
      path: "/edit/idea",
      name: "edit_idea",
      component: EditIdea,
    },
    {
      path: "/edit/lostandfound",
      name: "edit_lostandfound",
      component: EditLostandfound,
    },
    {
      path: "/message",
      name: "message",
      component: MessageIndex,
    },
    {
      path: "/message/chat",
      name: "message_chat",
      component: MessageChat,
    },
    {
      path: "/message/reply",
      name: "message_reply",
      component: MessageReply,
    },
    {
      path: "/message/atme",
      name: "message_atme",
      component: MessageAtme,
    },
    {
      path: "/message/system",
      name: "message_system",
      component: MessageSystem,
    },
    {
      path: "/account",
      name: "account",
      component: AccountIndex,
    },
    {
      path: "/account/login",
      name: "account_login",
      component: AccountLogin,
    },
    {
      path: "/account/register",
      name: "account_register",
      component: AccountRegister,
    },
    {
      path: "/account/password/find",
      name: "account_password_find",
      component: AccountPasswordFind,
    },
    {
      path: "/account/password/change",
      name: "account_password_change",
      component: AccountPasswordChange,
    },
    {
      path: "/account/bind/phone",
      name: "account_bind_phone",
      component: AccountBindPhone,
    },
    {
      path: "/account/bind/email",
      name: "account_bind_email",
      component: AccountBindEmail,
    },
    {
      path: "/account/userinfo",
      name: "account_userinfo",
      component: AccountUserinfo,
    },
    {
      path: "/account/userindex",
      name: "account_userindex",
      component: AccountUserindex,
    },
    {
      path: "/friend/search",
      name: "friend_search",
      component: FriendSearch,
    },
    {
      path: "/friend/request",
      name: "friend_request",
      component: FriendRequestIndex,
    },
    {
      path: "/friend/request/list",
      name: "friend_request_list",
      component: FriendRequestList,
    },
    {
      path: "/friend/request/handle",
      name: "friend_request_handle",
      component: FriendRequestHandle,
    },
    {
      path: "/friend/list",
      name: "friend_list",
      component: FriendList,
    },
    {
      path: "/friend/setting/markname",
      name: "friend_setting_markname",
      component: FriendSettingMarkname,
    },
    {
      path: "/user/collect",
      name: "user_collect",
      component: UserCollect,
    },
    {
      path: "/user/fellow",
      name: "user_fellow",
      component: UserFellow,
    },
    {
      path: "/user/viewrecord",
      name: "user_viewrecord",
      component: UserViewrecord,
    },
    {
      path: "/user/release",
      name: "user_release",
      component: UserRelease,
    },
    {
      path: "/user/comment",
      name: "user_comment",
      component: UserComment,
    },
    {
      path: "/advice",
      name: "advice",
      component: Advice,
    },
    {
      path: "/report",
      name: "report",
      component: Report,
    },
    {
      path: "/search",
      name: "search",
      component: SearchIndex,
    },
    {
      path: "/search/result",
      name: "search_result",
      component: SearchResult,
    },
    {
      path: "/topic",
      name: "topic",
      component: Topic,
    },
    {
      path: "/comment",
      name: "comment",
      component: Comment,
    },
  ],
});
